home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / libx11 / include / x11 / xkw / padp.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  4KB  |  119 lines

  1. /*
  2.  * $NCD$
  3.  *
  4.  * Copyright 1992 Network Computing Devices
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of NCD. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  NCD. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Keith Packard, Network Computing Devices
  24.  */
  25. #ifndef _PadP_h
  26. #define _PadP_h
  27.  
  28. #include "Pad.h"
  29. /* include superclass private header file */
  30. #include <X11/Xaw/SimpleP.h>
  31.  
  32. typedef struct {
  33.     int empty;
  34. } PadClassPart;
  35.  
  36. typedef struct _PadClassRec {
  37.     CoreClassPart    core_class;
  38.     SimpleClassPart    simple_class;
  39.     PadClassPart    pad_class;
  40. } PadClassRec;
  41.  
  42. extern PadClassRec padClassRec;
  43.  
  44. typedef struct _PadLine {
  45.     long    serial;
  46.     long    id;
  47.     char    *text;
  48.     char    *attr;
  49. } PadLineRec, *PadLinePtr;
  50.  
  51. typedef struct _PadCopy {
  52.     struct _PadCopy *next;
  53.     int            src, dst, amt;
  54.     unsigned long   copy_serial;
  55. } PadCopyRec, *PadCopyPtr;
  56.  
  57. typedef struct {
  58.     /* resources */
  59.     XFontStruct        *font;
  60.     unsigned long   foreground_pixel;
  61.     Dimension        rows, cols;
  62.     Dimension        internal_border;
  63.     /* private state */
  64.     GC            normal_gc;
  65.     GC            inverse_gc;
  66.     PadLinePtr        is;
  67.     PadLinePtr        want;
  68.     int            underline_pos;
  69.     int            underline_thickness;
  70.     int            char_width;
  71.     int            char_height;
  72.     int            char_vAdjust;
  73.     int            char_hAdjust;
  74.     unsigned long   serial;
  75.     Boolean        fixed_width;
  76.     PadCopyPtr        copy;
  77. } PadPart;
  78.  
  79. #define New(t) (t *) malloc(sizeof (t))
  80. #define Dispose(p)  free((char *) p)
  81. #define Some(t,n)   (t*) malloc(sizeof(t) * n)
  82. #define More(p,t,n) ((p)? (t *) realloc((char *) p, sizeof(t)*n):Some(t,n)
  83.  
  84. #define AllocText(b, cols) (\
  85.     (b)->text = Some(char, (cols)+1),\
  86.     (b)->attr = Some(char, (cols)+1),\
  87.     Clear (b, cols))
  88.                  
  89. #define DisposeText(b) (Dispose ((b)->text), Dispose ((b)->attr))
  90.     
  91. #define CopyText(fromb, tob, col, num) (\
  92.     bcopy((fromb)->text + col, (tob)->text + col, num), \
  93.     bcopy((fromb)->attr + col, (tob)->attr + col, num))
  94.  
  95. #define NextSerial(w)    (++(w)->pad.serial)
  96.              
  97. #define XPos(w,col)    ((w)->pad.internal_border + (col) * (w)->pad.char_width)
  98. #define YPos(w,row)    ((w)->pad.internal_border + (row) * (w)->pad.char_height)
  99. #define TextX(w,col)    ((w)->pad.char_hAdjust + XPos(w, col))
  100. #define TextY(w,row)    ((w)->pad.char_vAdjust + YPos(w, row))
  101.  
  102. #define ColPos(w,x)    (((x)-(int)(w)->pad.internal_border) /\
  103.              (int)(w)->pad.char_width)
  104. #define RowPos(w,y)    (((y)-(int)(w)->pad.internal_border) /\
  105.              (int)(w)->pad.char_height)
  106.  
  107. typedef struct _PadRec {
  108.     CorePart        core;
  109.     SimplePart        simple;
  110.     PadPart        pad;
  111. } PadRec;
  112.  
  113. /* declare specific PadWidget class and instance datatypes */
  114.  
  115. typedef struct _PadClassRec*        PadWidgetClass;
  116. typedef struct _PadRec*            PadWidget;
  117.  
  118. #endif /* _PadP_h */
  119.